import {ums} from '@/utils/request'
import {
  UmsListReq,
  UmsListType,
  UmsLoginReq,
  UmsLoginRes,
  UmsMenuListRes,
  UmsMenuReq,
  UmsMenuUpdateReq,
  UmsparentListRes,
  UmsPassReq,
  UserType
} from '@/type/ums'
import {MenuListQuery} from '@/view/system/menu/MenuType'
import {
  RoleFormDateType,
  RoleListType,
  RoleMenuModalType,
  RoleSaveType,
  RoleStatusType,
  RoleUserModalType
} from '@/view/system/role/RoleType'
import {
  UserAddType,
  UserListType,
  UserQueryType,
  UserUpdateType
} from '@/view/system/user/UserTypes'

// 登录
export const ums_login = (data: UmsLoginReq) => ums.post<UmsLoginRes>("login", data)
// 验证码
export const ums_code = () => ums.get<{
  text: string
  uuid: string
}>("code")
// 修改密码
export const ums_pass = (data: UmsPassReq) => ums.post<string>("pass", data)
// 获取左侧菜单
export const ums_menulist = () => ums.get<UmsparentListRes[]>("menulist")

/// 菜单
// 添加
export const ums_menu_save = (data:UmsMenuReq) => ums.post<string>("menu/save", data)
// 上级目录
export const ums_menu_parentList = () => ums.get<UmsparentListRes[]>("menu/parentList")
//编辑
export const ums_menu_update = (data:UmsMenuUpdateReq) => ums.post("menu/update", data)
//删除
export const ums_menu_delete = (data: {id:string}) => ums.del<string>("menu/delete", data)
//查询
export const ums_menu_list = (data:UmsListReq<MenuListQuery>) => ums.post<UmsMenuListRes>("menu/list", data)

/// 角色
// 查询
export const ums_role_list = (data:UmsListReq<RoleFormDateType>) => ums.post<UmsListType<RoleListType[]>>("role/list", data)
// 状态修改
export const ums_role_status = (data:RoleStatusType) => ums.post<string>("role/status", data)
// 添加
export const ums_role_save = (data:RoleSaveType) => ums.post<string>("role/save", data)
// 编辑
export const ums_role_update = (data: RoleListType) => ums.post<string>("role/update", data)
// 删除
export const ums_role_delete = (params:{roleId: string}) => ums.del("role/delete", params)
// 查询已授权用户
export const ums_role_userList = (params:{roleId: string}) => ums.get<UserType[]>("role/userList", params)
// 授权用户
export const ums_role_userImpower = (data:RoleUserModalType) => ums.post("role/userImpower", data)
// 查询当前角色授权的菜单
export const ums_role_menuList = (params:{roleId: string}) => ums.get<string[]>("role/menuList", params)
//  授权菜单
export const ums_role_menuImpower = (data:RoleMenuModalType) => ums.post('role/menuImpower', data)
/// 用户
//  查询所有用户
export const ums_user_queryList = () => ums.get<UserType[]>("user/queryList")
export const ums_user_list = (data:UmsListReq<UserQueryType>) => ums.post<UmsListType<UserListType[]>>("user/list", data)
export const ums_user_delete = (params: {id: number}) => ums.del("user/delete", params)
export const ums_user_update = (data: UserUpdateType) => ums.post("user/update", data)
export const ums_user_save = (data: UserAddType) => ums.post("user/save", data)

// 删除图片
export const ums_imgdel = (data: {url: string}) => ums.post("imgdel", data)


// 统计信息
export const ums_stat_stat = () => ums.get("stat/stat")
